home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
newgrp32.fr_
/
newgrp32.fr
Wrap
Text File
|
1995-09-04
|
4KB
|
152 lines
VERSION 4.00
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Create Group"
ClientHeight = 2100
ClientLeft = 1080
ClientTop = 1530
ClientWidth = 4980
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 2505
Left = 1020
LinkTopic = "Form1"
ScaleHeight = 2100
ScaleWidth = 4980
Top = 1185
Width = 5100
Begin VB.TextBox txtGroupName
Height = 315
Left = 2160
TabIndex = 3
Top = 360
Width = 2115
End
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "Cl&ose"
Height = 555
Left = 2520
TabIndex = 2
Top = 1080
Width = 1755
End
Begin VB.CommandButton cmdCreateGroup
Caption = "&Create Group"
Default = -1 'True
Height = 555
Left = 480
TabIndex = 1
Top = 1080
Width = 1755
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackColor = &H00C0C0C0&
Caption = "&Group name:"
Height = 195
Left = 780
TabIndex = 0
Top = 420
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Private Declare Function GetPrivateProfileString _
Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpSectionName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal Size As Integer, _
ByVal lpFileName As String) As Integer
Private Sub Form_Load()
Dim myUser As String, myPass As String
Dim winDir As String * 128
Dim dirLen As Integer
On Error GoTo LoadError
' Set the user and passwords for initial login.
myUser = "Admin"
myPass = "theboss"
' read VBDBHT.INI to get the name of the system database,
' then assign that name to the SystemDB property
DBEngine.SystemDB = GetSystemDatabase()
' log in
DBEngine.DefaultUser = myUser
DBEngine.DefaultPassword = myPass
Exit Sub
LoadError:
MsgBox Err & " " & Error$
End
End Sub
Private Sub cmdCreateGroup_Click()
Dim newGroup As Group
Dim thePID As String
On Error GoTo ChangeError
If txtGroupName = "" Then Error 32765
thePID = txtGroupName
If Len(thePID) > 20 Then
thePID = Left$(thePID, 20)
Else
Do While Len(thePID) < 4
thePID = thePID & "_"
Loop
End If
Set newGroup = DBEngine.Workspaces(0).CreateGroup(txtGroupName, thePID)
DBEngine.Workspaces(0).Groups.Append newGroup
MsgBox "Group " & txtGroupName & " created", vbInformation
txtGroupName = ""
Exit Sub
ChangeError:
Dim msg As String
Select Case Err.Number
Case 3390
msg = "There is already a group named " & txtGroupName
Case 32765
msg = "You have not entered a group name"
Case Else
msg = Err.Description
End Select
MsgBox msg, vbExclamation
End Sub
Private Sub cmdClose_Click()
End
End Sub
Private Function GetSystemDatabase() As String
' Returns the name of the system directory
Const INI_FILENAME = "VBDBHT.INI"
Const MAX_PATH = 128
Dim lpReturnedString As String * MAX_PATH
Dim bytesBack As Integer
bytesBack = GetPrivateProfileString("Options", _
"SystemDB", "", lpReturnedString, MAX_PATH, INI_FILENAME)
GetSystemDatabase = IIf(bytesBack > 0, Left$(lpReturnedString, bytesBack), "")
End Function